#!/usr/bin/python
# David Balduzzi    05/2008
# Virgil Griffith   01/2009
############################################################################################################
# This file contains various connection matrices that we can import into our various scripts.
############################################################################################################

from numpy import array, arange

# Balduzzi examples
######################################################

v_test3=array([
[0, 0, 1],
[0, 1, 1],
[0, 1, 0],
])

and4=array([
[0,1,1,1],
[1,0,1,1],
[1,1,0,1],
[1,1,1,0],
])          

testand=array([
[0,0,1],
[0,0,1],
[0,0,0],
])          

checker5=array((
[0,1,0,1,0],
[1,0,1,0,1],
[0,1,0,1,0],
[1,0,1,0,1],
[0,1,0,1,0],
))  

checker6=array((
[0,1,0,1,0,1],
[1,0,1,0,1,0],
[0,1,0,1,0,1],
[1,0,1,0,1,0],
[0,1,0,1,0,1],
[1,0,1,0,1,0],
))  

checker7=array((
[0,1,0,1,0,1,0],
[1,0,1,0,1,0,1],
[0,1,0,1,0,1,0],
[1,0,1,0,1,0,1],
[0,1,0,1,0,1,0],
[1,0,1,0,1,0,1],
[0,1,0,1,0,1,0],
))  


fiver=array((
[1,0,1,0,1],
[1,1,1,1,1],
[1,0,1,0,1],
[0,1,0,1,0],
[0,1,0,1,0],
))  



######################################

# game of life grid configurations
meth  =array(([0,1,0,0],[0,0,0,0],[1,1,1,0],[0,0,0,0]))
glider=array(([0,1,0,0],[0,0,1,0],[1,1,1,0],[0,0,0,0]))
#glider2=phi.run_life(glider)
#glider3=phi.run_life(glider2)
#glider4=phi.run_life(glider3)
#glider5=phi.run_life(glider4)
#glider_a=array(([1,1,1,0],[1,0,0,0],[0,1,0,0],[0,0,0,0]))
boat  =array(([1,1,0,0],[1,0,1,0],[0,1,0,0],[0,0,0,0]))
blink =array(([0,0,0,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]))
line=array(([0,0,0,0],[1,1,1,1],[0,0,0,0],[0,0,0,0]))

# Hopfield network
xi8=array(([0,0,0,0,1,1,1,1],[0,0,1,1,0,0,1,1],[0,1,0,1,0,1,0,1]))
xi16=array((
[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1],
[0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1],
[0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1]
))

nneutr=array(([1,1,1,1,1,1,0,1]))
ntense=array(([0,1,1,0,1,1,0,1]))
tense1=array(([0,1,1,0,1,0,0,1]))
tense2=array(([1,0,0,1,0,1,1,0]))

hFIFS=array((
[      0, -0.7500,  0.5000,  0.3750, -0.2500,  0.6250,       0,       0],
[      0,       0,       0,       0,       0, -0.7500, -0.8750,       0],
[ 0.1250,       0,       0, -1.0000,       0,  0.1250,       0,  0.8750],
[-0.7500,  0.1250,  0.5000,       0,       0, -0.7500,       0,       0],
[-0.3750, -0.2500, -0.3750,  0.7500,       0, -0.8750, -0.3750, -0.5000],
[      0,       0, -0.2500, -0.8750, -0.5000,       0,  0.7500,       0],
[ 0.5000,       0,       0,  0.2500,  0.7500,  0.1250,       0,  0.6250],
[      0,  0.8750,       0, -0.8750, -0.2500, -0.2500,  1.0000,       0]
))

chunks4_16=[array(([0,1,4,5])),array(([2,3,6,7])),array(([8,9,12,13])),array(([10,11,14,15]))]
chunks2_16=[arange(0,8),arange(8,16)]
chunks_ac_16=[
array(([0,4])),array(([1,2,5,6])),array(([3,7])),
array(([8,12])),array(([9,10,13,14])),array(([11,15]))
]


# deterministic systems

# ff hierarchy grid: 5-4-3-2-1
gffh=array((
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
))

# grid with dead edges and unidirectional arrows
g4_1d=array((
[0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
))  
g3_1d=array((
[0,1,0,1,0,0,0,0,0],
[0,0,1,0,1,0,0,0,0],
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0],
))  
g2_1d=array((
[0,1,1,0],
[0,0,0,1],
[0,0,0,1],
[0,0,0,0],
))

# grid with toroidal edges and unidirectional arrows
g4_1t=array((
[0,1,0,0,1,0,0,0,0,0,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0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0]
))
g3_nd=array((
[ 0,  1,  0,  1,  1,  0,  0,  0,  0],
[ 1,  0,  1,  1,  1,  1,  0,  0,  0],
[ 0,  1,  0,  0,  1,  1,  0,  0,  0],
[ 1,  1,  0,  0,  1,  0,  1,  1,  0],
[ 1,  1,  1,  1,  0,  1,  1,  1,  1],
[ 0,  1,  1,  0,  1,  0,  0,  1,  1],
[ 0,  0,  0,  1,  1,  0,  0,  1,  0],
[ 0,  0,  0,  1,  1,  1,  1,  0,  1],
[ 0,  0,  0,  0,  1,  1,  0,  1,  0]
))
g2_nd=array((
[0,1,1,1],
[1,0,1,1],
[1,1,0,1],
[1,1,1,0]
))

# grids with neighbors, torus edges
g4_nt=array((
[0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1],
[1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1],
[1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1],
[1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0],
[1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1],
[0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1],
[0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1],
[1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1],
[1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1],
[1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0]
))
g3_nt=array((
[0, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 0]
))
g2_nt=array((
[0,1,1,1],
[1,0,1,1],
[1,1,0,1],
[1,1,1,0]
))

# motifs
m9=array(([0,1,1],[0,1,0],[0,0,1]))
m46=array(([0,1,1,0],[1,0,0,0],[1,0,0,1],[0,0,0,0]))
m95=array(([0,1,1,0],[1,0,0,0],[1,0,0,1],[0,0,1,0]))
m148=array(([0,1,1,0],[1,0,0,0],[1,0,0,1],[0,1,1,0]))
m159=array(([0,1,1,1],[1,0,0,0],[1,0,0,1],[1,0,1,0]))
m178=array(([0,1,1,0],[1,0,0,1],[1,0,0,1],[0,1,1,0]))
m194=array(([0,1,1,1],[1,0,1,0],[1,1,0,1],[1,0,1,0]))


# 4x4 GoL grid, with elements 5,9 forced to have directed outputs
dird=array((
[11,  1,  0,  0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],
[ 1, 11,  1,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0],
[ 0,  1, 11,  1,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0],
[ 0,  0,  1, 11,  0,  0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0],
[ 1,  1,  0,  0, 11,  1,  0,  0,  1,  1,  0,  0,  0,  0,  0,  0],
[ 0,  0,  0,  0,  0, 11,  1,  0,  0,  1,  1,  0,  0,  0,  0,  0],
[ 0,  1,  1,  1,  0,  1, 11,  1,  0,  1,  1,  1,  0,  0,  0,  0],
[ 0,  0,  1,  1,  0,  0,  1, 11,  0,  0,  1,  1,  0,  0,  0,  0],
[ 0,  0,  0,  0,  1,  1,  0,  0, 11,  1,  0,  0,  1,  1,  0,  0],
[ 0,  0,  0,  0,  0,  1,  1,  0,  0, 11,  1,  0,  0,  0,  0,  0],
[ 0,  0,  0,  0,  0,  1,  1,  1,  0,  1, 11,  1,  0,  1,  1,  1],
[ 0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1, 11,  0,  0,  1,  1],
[ 0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0, 11,  1,  0,  0],
[ 0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  1, 11,  1,  0],
[ 0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  1, 11,  1],
[ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1, 11]
))

# optimized permutation with no self-connections
nscpm=array([
[0,  1,  1,  1], 
[1,  0,  0,  1], 
[1,  1,  1,  0], 
[0,  0,  0,  0], 
[1,  1,  0,  0], 
[1,  0,  1,  0], 
[0,  1,  0,  1], 
[0,  0,  1,  1], 
[0,  0,  0,  1], 
[1,  1,  0,  1], 
[1,  0,  0,  0], 
[0,  1,  0,  0], 
[1,  0,  1,  1], 
[1,  1,  1,  1], 
[0,  0,  1,  0], 
[0,  1,  1,  0]
])



c1=array([
[0,1,0,0,0,0,0,1],
[1,0,1,0,0,0,0,0],
[0,1,0,1,0,0,0,0],
[0,0,1,0,1,0,0,0],
[0,0,0,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1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
])
modular=array([
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]
])
optim8=array([
[0,0,0,0,0,0,1,0],
[1,0,0,0,0,0,0,0],
[0,0,0,1,0,0,1,1],
[0,1,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0],
[0,1,0,0,1,0,0,0],
[0,0,0,0,0,0,0,1],
[1,0,0,0,1,0,0,0]
])

hfifs=array([
[ 0.    , 0.875 ,-0.375 , 0.   ,  0.    ,-0.875 , 0.75 , -0.   ],
[ 0.5   , 0.    ,-0.375 , 1.   ,  0.875 ,-0.125 , 0.5  ,  0.5  ],
[-0.25  ,-0.875 , 0.    , 0.125,  0.125 , 0.    , 0.5  ,  0.   ],
[ 0.75  ,-0.375 , 0.    , 0.   , -0.125 , 0.    ,-0.75 ,  0.   ],
[-0.625 , 0.    ,-0.875 , 0.   ,  0.    ,-1.    , 1.   ,  0.   ],
[ 0.    ,-0.625 , 0.75  , 0.   , -0.375 , 0.    ,-0.5  ,  0.   ],
[-0.875 ,-0.    , 0.5   , 0.   , -0.125 ,-0.5   , 0.   , -0.25 ],
[-0.75  ,-0.25  ,-0.    ,-0.375,  0.    , 0.25  ,-0.875,  0.   ]
])

ff_red=array([
[0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,1,0,0],
[0,1,0,0,0,0,0,1,0,0],
[0,0,1,0,0,0,0,0,1,0],
[0,0,1,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0]
])

ff_nred=array([
[0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,1,0,0],
[0,1,0,0,0,0,0,0,1,0],
[0,0,1,0,0,0,0,1,0,0],
[0,0,1,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0]
])

ff_gslic10=array([
[0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,0],
[0,1,1,0,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0],
[0,0,0,1,1,0,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0],
[0,0,0,0,0,1,0,0,0,0]
])
ff_gslic15=array([
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]
])

# scrambled and counting, plug into perm_adj
counting=array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
scrambled=array([8,0,7,13,15,10,2,5,14,3,9,4,1,11,6,12])



############################################################################################################
# Virgil examples
############################################################################################################

# These are for staged AND-gates
andgates = {
 2: array([
[0,0,1],
[0,0,1],
[0,0,0] ]),
 3: array([
[0,0,0,1,0],
[0,0,0,1,0],
[0,0,0,0,1],
[0,0,0,0,1],
[0,0,0,0,0] ]),
 4: array([ 
[0,0,0,0,1,0,0],
[0,0,0,0,1,0,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,0,1],
[0,0,0,0,0,0,1],
[0,0,0,0,0,0,0] ]),
5: array([
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0] ]),
6: array([ 
[0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0] ])
}

# Hierachrical AND-gates with a single back connection.
andgates_with_backcns = {
 2: array([
[0,0,1],
[0,0,1],
[0,1,0] ]),
 3: array([
[0,0,0,1,0],
[0,0,0,1,0],
[0,0,0,0,1],
[0,0,0,0,1],
[0,0,0,1,0] ]),
 4: array([ 
[0,0,0,0,1,0,0],
[0,0,0,0,1,0,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,0,1],
[0,0,0,0,0,0,1],
[0,0,0,0,0,1,0] ]),
5: array([
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,1,0] ]),
6: array([ 
[0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,1,0] ])
}

# Figure 2b from Balduzzi, Tononi (2008)
Fig2b=array([
[0,1,1],
[1,0,1],
[1,1,0],
])

# Three disconnected AND gates.
disc3ands=array([
[0,0,1,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0],
])


